<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>体检预约系统 - 客户查询</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }
       
        body {
            background-color: #f5f7fa;
            color: #333;
        }
       
        .container {
            width: 95%;
            max-width: 1200px;
            margin: 20px auto;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }
       
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }
       
        .header h1 {
            font-size: 1.8rem;
            color: #2c3e50;
        }
       
        .header i {
            color: #4facfe;
            margin-right: 8px;
        }
       
        .search-area {
            background-color: #f8f9fa;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
        }
       
        .search-form {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
        }
       
        .form-group {
            flex: 1;
            min-width: 200px;
        }
       
        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #555;
        }
       
        .form-group input, .form-group select {
            width: 100%;
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 1rem;
        }
       
        .form-group input:focus, .form-group select:focus {
            border-color: #4facfe;
            outline: none;
        }
       
        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s;
        }
       
        .btn-primary {
            background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
            color: white;
        }
       
        .btn-secondary {
            background-color: #f8f9fa;
            border: 1px solid #ddd;
            color: #555;
        }
       
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
        }
       
        .btn i {
            margin-right: 5px;
        }
       
        .table-container {
            overflow-x: auto;
        }
       
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
       
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }
       
        th {
            background-color: #f8f9fa;
            font-weight: bold;
            color: #2c3e50;
        }
       
        tr:hover {
            background-color: #f1f7fe;
        }
       
        .status {
            display: inline-block;
            padding: 5px 10px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: bold;
        }
       
        .status-completed {
            background-color: #d4edda;
            color: #155724;
        }
       
        .status-pending {
            background-color: #fff3cd;
            color: #856404;
        }
       
        .status-canceled {
            background-color: #f8d7da;
            color: #721c24;
        }
       
        .action-btn {
            padding: 5px 10px;
            margin-right: 5px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.9rem;
        }
       
        .view-btn {
            background-color: #4facfe;
            color: white;
        }
       
        .edit-btn {
            background-color: #ffc107;
            color: #333;
        }
       
        .delete-btn {
            background-color: #dc3545;
            color: white;
        }
       
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }
       
        .pagination button {
            margin: 0 5px;
            padding: 8px 12px;
            border: 1px solid #ddd;
            background-color: white;
            cursor: pointer;
            border-radius: 4px;
        }
       
        .pagination button.active {
            background-color: #4facfe;
            color: white;
            border-color: #4facfe;
        }
       
        .no-data {
            text-align:center;
            padding: 40px;
            color: #777;
        }
       
        @media (max-width: 768px) {
            .header {
                flex-direction: column;
                align-items: flex-start;
            }
           
            .header h1 {
                margin-bottom: 10px;
            }
           
            .form-group {
                min-width: 100%;
            }
           
            th, td {
                padding: 8px 10px;
                font-size: 0.9rem;
            }
        }
    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css";>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1><i class="fas fa-search"></i>体检客户查询</h1>
            <div>
                <button class="btn btn-primary" id="exportBtn">
                    <i class="fas fa-file-export"></i>导出数据
                </button>
            </div>
        </div>
       
        <div class="search-area">
            <form class="search-form" id="searchForm">
                <div class="form-group">
                    <label for="name">客户姓名</label>
                    <input type="text" id="name" placeholder="请输入客户姓名">
                </div>
               
                <div class="form-group">
                    <label for="idCard">身份证号</label>
                    <input type="text" id="idCard" placeholder="请输入身份证号">
                </div>
               
                <div class="form-group">
                    <label for="phone">手机号码</label>
                    <input type="text" id="phone" placeholder="请输入手机号码">
                </div>
               
                <div class="form-group">
                    <label for="status">体检状态</label>
                    <select id="status">
                        <option value="">全部</option>
                        <option value="completed">已完成</option>
                        <option value="pending">待检</option>
                        <option value="canceled">已取消</option>
                    </select>
                </div>
               
                <div class="form-group">
                    <label for="date">体检日期</label>
                    <input type="date" id="date">
                </div>
               
                <div class="form-group" style="align-self: flex-end;">
                    <button type="button" class="btn btn-secondary" id="resetBtn">
                        <i class="fas fa-redo"></i>重置
                    </button>
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-search"></i>查询
                    </button>
                </div>
            </form>
        </div>
       
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>客户姓名</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>手机号码</th>
                        <th>体检套餐</th>
                        <th>预约日期</th>
                        <th>体检状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="customerTable"><!-- 数据将通过JavaScript动态加载 -->
                </tbody>
            </table>
           
            <div id="noData" class="no-data" style="display: none;">
                <i class="fas fa-info-circle" style="font-size: 2rem; margin-bottom: 10px;"></i>
                <p>没有找到符合条件的客户数据</p>
            </div>
        </div>
       
        <div class="pagination">
            <button id="prevPage"><i class="fas fa-chevron-left"></i></button>
            <button class="active">1</button>
            <button>2</button>
            <button>3</button>
            <button id="nextPage"><i class="fas fa-chevron-right"></i></button>
        </div>
    </div>

    <script>
        // 模拟数据
        const mockData = [
            {
                id: 1,
                name: "张三",
                gender: "男",
                age: 35,
                phone: "13800138001",
                package: "基础体检套餐",
                date: "2023-06-15",
                status: "completed"
            },
            {
                id: 2,
                name: "李四",
                gender: "女",
                age: 28,
                phone: "13800138002",
                package: "高级体检套餐",
                date: "2023-06-16",
                status: "pending"
            },
            {
                id: 3,
                name: "王五",
                gender: "男",
                age: 42,
                phone: "13800138003",
                package: "VIP尊享套餐",
                date: "2023-06-17",
                status: "completed"
            },
            {
                id: 4,
                name: "赵六",
                gender: "女",
                age: 31,
                phone: "13800138004",
                package: "基础体检套餐",
                date: "2023-06-18",
                status: "canceled"
            },
            {
                id: 5,
                name: "钱七",
                gender: "男",
                age: 50,
                phone: "13800138005",
                package: "中老年专项套餐",
                date: "2023-06-19",
                status: "pending"
            }
        ];// 渲染表格数据
        function renderTable(data) {
            const tableBody = document.getElementById('customerTable');
            const noDataDiv = document.getElementById('noData');
           
            tableBody.innerHTML = '';
           
            if (data.length === 0) {
                noDataDiv.style.display = 'block';
                return;
            }
           
            noDataDiv.style.display = 'none';
           
            data.forEach((item, index) => {
                const row = document.createElement('tr');
               
                // 状态标签
                let statusClass = '';
                let statusText = '';
               
                switch(item.status) {
                    case 'completed':
                        statusClass = 'status-completed';
                        statusText = '已完成';
                        break;
                    case 'pending':
                        statusClass = 'status-pending';
                        statusText = '待检';
                        break;
                    case 'canceled':
                        statusClass = 'status-canceled';
                        statusText = '已取消';
                        break;
                }
               
                row.innerHTML = `
                    <td>${index + 1}</td>
                    <td>${item.name}</td>
                    <td>${item.gender}</td>
                    <td>${item.age}</td>
                    <td>${item.phone}</td>
                    <td>${item.package}</td>
                    <td>${item.date}</td>
                    <td><span class="status ${statusClass}">${statusText}</span></td>
                    <td>
                        <button class="action-btn view-btn" data-id="${item.id}">查看</button>
                        <button class="action-btn edit-btn" data-id="${item.id}">编辑</button>
                        <button class="action-btn delete-btn" data-id="${item.id}">删除</button>
                    </td>
                `;
               
                tableBody.appendChild(row);
            });
           
            // 添加按钮事件
            document.querySelectorAll('.view-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const id = this.getAttribute('data-id');
                    alert(`查看客户ID: ${id}`);
                    // window.location.href = `detail.html?id=${id}`;
                });
            });
           
            document.querySelectorAll('.edit-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const id = this.getAttribute('data-id');
                    alert(`编辑客户ID: ${id}`);
                    // window.location.href = `edit.html?id=${id}`;
                });
            });
           
            document.querySelectorAll('.delete-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const id = this.getAttribute('data-id');
                    if (confirm(`确定要删除ID为 ${id} 的客户吗?`)) {
                        alert(`删除客户ID: ${id}`);
                        // 这里可以添加实际的删除逻辑
                    }
                });
            });
        }
// 初始化表格
        document.addEventListener('DOMContentLoaded', function() {
            renderTable(mockData);
           
            // 查询表单提交
            document.getElementById('searchForm').addEventListener('submit', function(e) {
                e.preventDefault();
                searchCustomers();
            });
           
            // 重置按钮

            document.getElementById('resetBtn').addEventListener('click', function() {
 document.getElementById('resetBtn').addEventListener('click', function() {
                document.getElementById('searchForm').reset();
                renderTable(mockData);
            });
           
            // 导出按钮
            document.getElementById('exportBtn').addEventListener('click', function() {
                alert('数据导出功能将在实际项目中实现');
                // 这里可以添加实际的导出逻辑
            });
           
            // 分页按钮
            document.querySelectorAll('.pagination button').forEach(btn => {
                if (!btn.id) {
                    btn.addEventListener('click', function() {
                        document.querySelector('.pagination button.active').classList.remove('active');
                        this.classList.add('active');
                        alert(`切换到第 ${this.textContent} 页`);
                        // 这里可以添加实际的分页逻辑
                    });
                }
            });
        });
       
        // 搜索客户
        function searchCustomers() {
            const name = document.getElementById('name').value.toLowerCase();
            const idCard = document.getElementById('idCard').value;
            const phone = document.getElementById('phone').value;
            const status = document.getElementById('status').value;
            const date = document.getElementById('date').value;
           
            const filteredData = mockData.filter(item => {
                return (name === '' || item.name.toLowerCase().includes(name)) &&
                       (idCard === '' || true) && // 模拟数据中没有身份证字段，实际项目中需要添加
                       (phone === '' || item.phone.includes(phone)) &&
                       (status === '' || item.status === status) &&
                       (date === '' || item.date === date);
            });
           
            renderTable(filteredData);
        }
    </script>
</body>
</html>
